﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DLTN.Entities;
using DLTN.Data;

public partial class Media_Controls_ControlMediaContent : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienThiMedia();
        }
    }

    private void HienThiMedia()
    {
        string strHTML = "";
        int TotalRows = 0;
        string WhereClause = "1=1";
        TList<LoaiChuyenMuc> TList_LoaiChuyenMuc = DataRepository.LoaiChuyenMucProvider.GetPaged("TenLoaiChuyenMuc like N'%" + Common.Media + "%'", "ID", 0, 0, out TotalRows);
        if (TList_LoaiChuyenMuc.Count > 0)
        {
            WhereClause += " and trangthai =1 and IdSubChuyenMuc in (select Id from SubChuyenMuc where IdLoaiChuyenMuc = " + TList_LoaiChuyenMuc[0].Id + " )";
            TList<ChuyenMuc> TList_ChuyenMuc = DataRepository.ChuyenMucProvider.GetPaged(WhereClause, "NgayCapNhat DESC", 0, 5, out TotalRows);
            if (TList_ChuyenMuc.Count > 0)
            {
                int j = 1;
                //Phần liệt kê
                for (int i = 0; i <= TList_ChuyenMuc.Count - 1; i++)
                {
                    strHTML += "<div id=\"li-content" + j + "\"><div style=\"float: left; margin-top: 5px;\">";
                    strHTML += "<div style=\"float: left; margin-left: 10px;\"><img src=\"images/dltn/caydua.png\" border=\"0\"></div>";
                    strHTML += "<div style=\"float: right; margin-left: 5px; margin-top: 7px\">";
                    strHTML += "<div style=\"color: #CC3300; font-weight: bold\"><a class=\"chuyenmucnoibat\" href='.'>TRANG CHỦ</a> » MEDIA</div>";
                    strHTML += "<div class=\"date-time\">" + Common.StandardStringjquery(TList_ChuyenMuc[i].NgayCapNhat.ToString("''  dd/MM/yyyy, HH:mm 'GMT+7'")) + "</div></div></div>";
                    strHTML += "<div class=\"MainItemImg\" >";
                    strHTML += "<a href='ChuyenMuc/" + TList_ChuyenMuc[i].Id + "/" + TList_ChuyenMuc[i].IdSubChuyenMuc + "/" + GetTieuDe(TList_ChuyenMuc[i].TieuDe) + ".aspx'>";
                    strHTML += "<img class=\"radius\" src='" + (TList_ChuyenMuc[i].AnhDaiDien == "no_image.jpg" ? "images/no_image.jpg" : "Upload/ChuyenMuc/" + TList_ChuyenMuc[i].AnhDaiDien) + "'\" border=\"0\" style='height:300px' ></a></div>";
                    strHTML += "<div ><a href='ChuyenMuc/" + TList_ChuyenMuc[i].Id + "/" + TList_ChuyenMuc[i].IdSubChuyenMuc + "/" + GetTieuDe(TList_ChuyenMuc[i].TieuDe) + ".aspx' class=\"seemoreText\">";
                    strHTML += "<div style=\"color:Red; font-size:14px; margin-top: 5px; font-weight: bold;\">" + TList_ChuyenMuc[i].TieuDe + "</div></a></div>";
                    strHTML += "<div class=\"MainItemText\" style='height: 55px;'>" + TList_ChuyenMuc[i].TomTat + "</div>";
                    strHTML += "<div style=\" padding-left: 529px; margin-top: -5px;\">";
                    strHTML += "<div class=\"seemoreDiv\"><a href='ChuyenMuc/" + TList_ChuyenMuc[i].Id + "/" + TList_ChuyenMuc[i].IdSubChuyenMuc + "/" + GetTieuDe(TList_ChuyenMuc[i].TieuDe) + ".aspx' class=\"seemoreText\">";
                    strHTML += "<div style=\"padding-top: 2px; padding-left: 2px\">Xem tiếp</div></a></div></div></div>";

                    //lblNgayCapNhat.Text = Common.StandardStringjquery(TList_ChuyenMuc[i].NgayCapNhat.ToString("'' dddd dd/MM/yyyy, HH:mm 'GMT+7'"));
                    j++;
                }
            }

        }

        litchuyenmuc.Text = strHTML;
    }

    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}